from random import choice

class RandomWalk:
    """随机漫步类"""

    def __init__(self, num_points=5000) -> None:
        """初始化"""

        self.num_points = num_points
        self.x_values = [0]
        self.y_values = [0]

    def fill_walk(self):
        """填充漫步数"""

        while len(self.x_values) < self.num_points:

            # 控制左右和步伐大小
            step = self.get_step()

            x_step = step
            y_step = step

            # 设置步伐
            x = self.x_values[-1] + x_step
            y = self.y_values[-1] + y_step
            self.x_values.append(x)
            self.y_values.append(y)

    def get_step(self) -> int:
        """获取步长"""

        direction = choice([1, -1])
        distances = choice([0,1,2,3,4])
        return direction * distances